<template>
	<view class="content">
		<view class="top">
			<uni-nav-bar left-icon="back" fixed="true" backgroundColor="linear-gradient(0deg, #cfad88 0%, #9e866a 100%)" title="搜索商品" color="white"
				@clickLeft="returnBack">
			</uni-nav-bar>
		</view>
		<view class="input-box flex">
			<view class="inputbox flex">
				<view class="image-box flex">
					<image src="/static/sousuo.png"></image>
				</view>
				<input class="input" placeholder="点击搜索商品" :focus="true" v-model="inputValue" />
			</view>
			<view class="text" @click="searchShop">搜索</view>
		</view>
		<view class="remen-box">热门搜索</view>
		<view class="item-box flex">
			<view class="item" v-for="(item,index) in dataList" :key="index" @click="addShop(item.name)">{{item.name}}</view>
		</view>
	</view>
</template>

<script>
	var _this;
	const app = getApp();
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	export default {
		components: {
			uniNavBar
		},
		data() {
			return {
				inputValue:'',
				dataList:[{name:'酒类'},{name:'腊肉'},{name:'特产'},{name:'手办'},{name:'床上用品'}]
			};
		},
		onLoad() {
			_this = this;
		},
		onShow() {
			
		},
		methods:{
			returnBack() {
				// #ifdef H5
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack(1)
					return;
				}
				//使用vue-router返回上一级
				let a = this.$router.go(-1)
				if (a == undefined) {
					//重新定向跳转页面
					uni.reLaunch({
						url: "/pages/index/index"
					})
				}
				return;
				// #endif
				uni.navigateBack(1)
			},
			searchShop(){
				uni.setStorageSync('shopValue', _this.inputValue);
				uni.redirectTo({
				    url: '/pages/index/index'
				});
			},
			addShop(name){
				_this.inputValue=name;
			}
		}
	}
</script>
<style lang="less">
	page {
		width: 100%;
		background: white;
	}
</style>
<style scoped lang="less">
	.content{
		width: 100%;
		.top {
			width: 100%;
			box-shadow: 0rpx -2rpx 0rpx 0rpx #D1D1D1;
		}
		.input-box{
			width: 100%;
			box-sizing: border-box;
			padding: 0 25rpx;
			margin-top: 20rpx;
			align-items: center;
			justify-content: space-between;
			.inputbox{
				width: 100%;
				height: 50rpx;
				background: #d5d5d5;
				box-shadow: 0rpx 0rpx 3rpx 0rpx rgba(0, 0, 0, 0.1);
				border-radius: 25rpx;
				box-sizing: border-box;
				padding: 0 30rpx;
				align-items: center;
				.image-box{
					width: 26rpx;
					height: 25rpx;
					image{
						width: 26rpx;
						height: 25rpx;
						align-items: center;
					}
				}
				.input{
					width: 100%;
					margin-left: 20rpx;
					font-size: 24rpx;
				}
			}
			.text{
				width: 120rpx;
				font-size: 28rpx;
				font-weight: bold;
				color: #000000;
				text-align: right;
			}
		}
		.remen-box{
			width: 100%;
			box-sizing: border-box;
			padding: 0 25rpx;
			margin-top: 52rpx;
			font-size: 24rpx;
			color: #010101;
		}
		.item-box{
			width: 100%;
			box-sizing: border-box;
			padding: 0 25rpx;
			margin-top: 10rpx;
			flex-wrap: wrap;
			.item{
				background: #d5d5d5;
				box-shadow: 0rpx 0rpx 3rpx 0rpx rgba(0, 0, 0, 0.1);
				border-radius: 10rpx;
				box-sizing: border-box;
				padding: 5rpx 20rpx;
				font-size: 24rpx;
				color: #737373;
				margin: 10rpx 15rpx 0 0 ;
			}
		}
	}
</style>
